import markdown
from weasyprint import HTML

# 将 Markdown 转换为 HTML
with open("tree_data.md", "r", encoding="utf-8") as f:
    md_text = f.read()
    html = markdown.markdown(md_text)

# 添加 CSS 样式
css = """
@font-face { font-family: "SimSun"; src: url("/path/to/simsun.ttf"); }
body { font-family: "SimSun"; }
"""

# 生成 PDF
HTML(string=html).write_pdf("output.pdf", stylesheets=[css])